<?php

namespace app\controllers;

use Yii;
use app\base\Controller;
use app\models\Menu;
use app\models\Admin;
use yii\helpers\Url;

use yii\mongodb\Query;
use yii\mongodb\ActiveRecord;
use yii\data\ActiveDataProvider;

class TestmongoController extends Controller
{


    // 测试
    public function actionIndex()
    {        
        Yii::$app->mongodb->getCollection('test')->insert(['name' => 'John Smith', 'status' => 123]);

        $query = new Query;
        // compose the query
        $query->select(['name', 'status'])
            ->from('test')
            ->limit(100);

        // execute the query
        $rows = $query->all();
        
        print_r($rows);
        echo '<br>';
        echo 'END';
        exit;
    }
}
